package com._520it.wms.query;

import com._520it.wms.util.DateUtil;
import com.alibaba.druid.util.StringUtils;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

@Getter
@Setter
//订货报表查询
public class OrderChartQueryObject extends QueryObject {
    //保证添加顺序
    public static Map<String, Object> groupTypes = new LinkedHashMap<>();

    static {
        groupTypes.put("inputUser.name", "订货人员");
        groupTypes.put("p.name", "货品名称");
        groupTypes.put("s.name", "供应商");
        groupTypes.put("p.brandName.name", "品牌");
        groupTypes.put("DATE_FORMAT(bill.vdate,'%Y-%m')","订货日期(月)");
        groupTypes.put("DATE_FORMAT(bill.vdate,'%Y-%m-%d')","订货日期(日)");


    }

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startDate;//开始时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endDate;//结束时间

    private String keyword;//货品名称或者编码
    private Long supplierId = -1L;//供应商id
    private Long brandId = -1L;//品牌
    private String groupType = "inputUser.name";// 分组信息


    public Date getStartDate() {
        return DateUtil.getStart(startDate);
    }

    public Date getEndDate() {
        return DateUtil.getEnd(endDate);
    }


    public String getKeyword() {
        if (StringUtils.isEmpty(keyword)) {
            return null;
        }
        return keyword.trim();//去空格

    }
}
